/**
 * @Title: AsyncEventBusBuilder
 * @Package com.fx.rh.sdkserver.web.eventbus
 * @Description: AsyncEventBusBuilder
 * @author yulin.xu@downjoy.com
 * @date 2017/5/23 0023 下午 2:05
 * @version V1.0
 */
package cn.com.artemis.biz.steinsggs.common.util;

import com.google.common.eventbus.AsyncEventBus;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import java.util.Set;

/**
 *
 *@ClassName: AsyncEventBusBuilder
 * @Description: AsyncEventBusBuilder
 * @author yulin.xu@downjoy.com
 * @date 2017/5/23 0023 下午 2:05
 *
 */
public class AsyncEventBusBuilder implements InitializingBean, DisposableBean {

    /**
     * eventbus 总线
     */
    private AsyncEventBus eventBus;

    /**
     * 处理器
     */
    private Set<Object> handlers;

    public void destroy() throws Exception {

    }

    public void afterPropertiesSet() throws Exception {
        for(Object handler: handlers) {
            eventBus.register(handler);
        }
    }

    /**
     * @param eventBus the eventBus to set
     */
    public void setEventBus(AsyncEventBus eventBus) {
        this.eventBus = eventBus;
    }

    /**
     * @param handlers the handlers to set
     */
    public void setHandlers(Set<Object> handlers) {
        this.handlers = handlers;
    }
}